﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectPaperList.aspx.cs"  Inherits="ExaminationSys.View.Paper.SelectPaperList" %>
 <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register src="PaperInfoSearchWindow.ascx" tagname="PaperInfoSearch" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript">
        var renderLevel = function(value) {
            switch (value) {
            case 1:
                return "高级";
            case 2:
                return "中级";
            case 3:
                return "初级";
            }
        };

        var renderDegree = function(value) {
            switch (value) {
            case 1:
                return "高";
            case 2:
                return "中";
            case 3:
                return "初";
            }
        };

        var renderType = function(value) {
            switch (value) {
            case 1:
                return "固定";
            case 2:
                return "自动";
            }
        };
        var CloseWin = function() {
            parent.win.hide();
        };

        var SelectPaper = function () {
            var selectedRow = Ext.select(".x-grid-row-selected");

            if (selectedRow.elements.length == 0) {
                Ext.Msg.alert("提示", "请选择一条试卷记录"); return false;
            }
            var paperId = selectedRow.elements[0].children["1"].children["0"].innerHTML;
            var paperTitle = selectedRow.elements[0].children["3"].children["0"].innerHTML;
            parent.win.setPaperInfo(paperId, paperTitle);

            parent.win.hide();
        };
      

       </script>

</head>
<body>
    <form id="Form1" runat="server">
     <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="X"  />
    <ext:Store ID="StorePaperInfo" runat="server" PageSize="20" ShowWarningOnFailure="true"
        AutoLoad="true" OnReadData="StorePaperInfo_RefreshData">
        <Proxy>
            <ext:PageProxy>
                <Listeners>
                    <Exception Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
                </Listeners>
            </ext:PageProxy>
        </Proxy>
        <Model>
            <ext:Model ID="PaperInfoModel" runat="server" IDProperty="ID">
                <Fields>
                    <ext:ModelField Name="ID" />
                    <ext:ModelField Name="SectionID" />
                    <ext:ModelField Name="SectionName" />
                    <ext:ModelField Name="PaperNo" />
                    <ext:ModelField Name="Title" />
                    <ext:ModelField Name="Level" />
                    <ext:ModelField Name="Degree" />
                    <ext:ModelField Name="Type" />
                    <ext:ModelField Name="Score" />
                    <ext:ModelField Name="Timeout" />
                    <ext:ModelField Name="Description" />
                    <ext:ModelField Name="Status" Type="Int" />
                    <ext:ModelField Name="Operator" />
                    <ext:ModelField Name="OperatorTime" Type="Date" />
                </Fields>
            </ext:Model>
        </Model>
        <AutoLoadParams>
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="20" Mode="Raw" />
        </AutoLoadParams>
        <Sorters>
            <ext:DataSorter Property="OpeatorTime" Direction="DESC" />
        </Sorters>
        <Listeners>
            <Exception Handler="Ext.MessageBox.alert('Load failed', response.statusText);">
            </Exception>
        </Listeners>
    </ext:Store>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="BorderLayout">
        <Items>
            <ext:GridPanel ID="GridPanelPaperInfo" runat="server" Region="Center" StoreID="StorePaperInfo"
                TrackMouseOver="true" AutoExpandColumn="Title">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:TextField ID="GroupSearchText" EmptyText="输入关键字" runat="server">
                            </ext:TextField>
                            <ext:Button runat="server" ID="BtnGroupFind" Text="查找" Icon="Find">
                                <DirectEvents>
                                    <Click OnEvent="BtnGroupFind_Click">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:Button runat="server" ID="BtnSearch" Text="高级查找" Icon="Find">
                                <DirectEvents>
                                    <Click OnEvent="BtnSearch_Click">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator />
                            <ext:Button runat="server" ID="BtnRefresh" Text="刷新" Icon="ArrowRefresh">
                                <Listeners>
                                    <Click Handler="#{StorePaperInfo}.reload();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="SaveButton" runat="server" Text="选择" Icon="BulletGo">
                                <Listeners>
                                    <Click Fn="SelectPaper" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="CancelButton" runat="server" Text="取消" Icon="Cancel">
                                <Listeners>
                                    <Click Fn="CloseWin" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <SelectionModel>
                    <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Single"
                        CheckOnly="true" />
                </SelectionModel>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Header="ID" DataIndex="ID" Width="150" Hidden="true" />
                        <ext:Column ID="Column5" runat="server" Header="编号" DataIndex="PaperNo" Width="40" />
                        <ext:Column ID="Column2" runat="server" Header="标题" DataIndex="Title" Width="180" />
                        <ext:Column ID="Column6" runat="server" Header="栏目" DataIndex="SectionName" Width="80" />
                        <ext:Column ID="Column7" runat="server" Header="阶段" DataIndex="Level" Width="60">
                            <Renderer Fn="renderLevel" />
                        </ext:Column>
                        <ext:Column ID="Column8" runat="server" Header="难度" DataIndex="Degree" Width="60">
                            <Renderer Fn="renderDegree" />
                        </ext:Column>
                        <ext:Column ID="Column9" runat="server" Header="类型" DataIndex="Type" Width="60">
                            <Renderer Fn="renderType" />
                        </ext:Column>
                        <ext:Column ID="Column3" runat="server" Header="总分" DataIndex="Score" Width="60" />
                        <ext:Column ID="Column4" runat="server" Header="测试时长(分钟)" DataIndex="Timeout" Width="100" />
                        <ext:Column ID="Column10" runat="server" Header="备注" DataIndex="Description" Width="100" />
                    </Columns>
                </ColumnModel>
                <Listeners>
                </Listeners>
                <View>
                    <ext:GridView ID="GridView1" runat="server" />
                </View>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" DisplayInfo="true" DisplayMsg="当前显示记录: {0} - {1}  共计: {2}"
                        EmptyMsg="没有记录可以显示" />
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
     <uc1:PaperInfoSearch ID="PaperInfoSearchWindow" runat="server" />
    </form>
</body>
</html>

